package com.ruoyi.lifecycle.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.mybatis.core.page.TableDataInfo;
import com.ruoyi.lifecycle.domain.TFund;
import com.ruoyi.lifecycle.domain.bo.TMileStoneBo;
import com.ruoyi.lifecycle.domain.vo.TFundVo;
import com.ruoyi.lifecycle.domain.vo.TMileStoneVo;
import com.ruoyi.lifecycle.domain.vo.TimeLineEvenVo;
import com.ruoyi.lifecycle.mapper.TFundMapper;
import com.ruoyi.lifecycle.service.ITFundService;
import com.ruoyi.lifecycle.service.TMileStoneService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.List;

/**
 * @Author Zzneko
 * @Date 2025/6/9 14:27
 * @Descprition
 **/
@Service
@RequiredArgsConstructor
public class TMileStoneServiceImpl implements TMileStoneService {

    private final ITFundService itFundService;
    private final TFundMapper baseMapper;

    @Override
    public R<TMileStoneVo> getTMileStoneInfos(TMileStoneBo bo) {
        List<TimeLineEvenVo> mileStoneInfos = itFundService.getMileStoneInfos(bo);
        QueryWrapper<TFund> qw = new QueryWrapper<>();
        qw.lambda().eq(TFund::getFundcode, bo.getFundCode());
        TFund tFund = baseMapper.selectOne(qw);
        TMileStoneVo stoneVo = new TMileStoneVo();
        stoneVo.setFundCode(tFund.getFundcode());
        stoneVo.setFundStatus(tFund.getFundstatus());
        stoneVo.setFundIntendDate(tFund.getFundintenddate());
        stoneVo.setFundName(tFund.getFundname());
        stoneVo.setFundEnglishName(tFund.getFundenglishname());
        stoneVo.setTimeLineEvenVos(mileStoneInfos);
        stoneVo.setSubAmountLast(String.valueOf(tFund.getSubamountlast()));
        return R.ok(stoneVo);
    }
}
